<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreateCompanyCategoryTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('company_category', function (Blueprint $table) {
            $table->increments('id');
            $table->string('name')->comment('分类名称');
            $table->string('uri')->comment('目录名称');
            $table->timestamps();
        });

        Schema::table('company_material_task', function (Blueprint $table) {
            if (!Schema::hasColumn('company_material_task', 'category_id')) {
                $table->unsignedBigInteger('category_id')->comment('分类id');
            }
        });

        Schema::table('company_material', function (Blueprint $table) {
            if (!Schema::hasColumn('company_material', 'category_id')) {
                $table->unsignedBigInteger('category_id')->comment('分类id');
            }
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('company_category');
    }
}
